(function () {
    // baseurl
    var baseUrl = './';
    // 资源加载
    var queue = new createjs.LoadQueue(true);
    var fest = [
        baseUrl + 'img/bg.jpg',
        baseUrl + 'img/scene1.png',
        baseUrl + 'img/scene2.png',
        baseUrl + 'img/scene3.png',
        baseUrl + 'img/scene4.png',
        baseUrl + 'img/wxList01.png',
        baseUrl + 'img/wxList02.png',
        baseUrl + 'img/wxList03.png',
        baseUrl + 'img/wxList04.png',
        baseUrl + 'sound/bg01.mp3',
        baseUrl + 'sound/talkMusic.mp3',
        baseUrl + 'sound/wxMsg.mp3',
        baseUrl + 'sound/btn.mp3',
    ]
    var progress = 0;
    queue.loadManifest(fest);
    queue.on("fileload", function () {
        progress++;
        var _prop = parseInt(progress / fest.length * 100);
        $('.loadCur').width(_prop + '%')
    }, this);
    queue.on("complete", function () {
        $(".loadDom").fadeOut("fast");
        $(".wrap").fadeIn("fast");
    }, this);

})();


var audio = document.getElementById("audio");

function music() {
    audio.play();
    $(".btn_music").on('touchstart', function () {
        if (!audio.paused) {
            audio.pause();
            $(".btn_music>img").attr("src", "img/stop.png")
        } else {
            audio.play();
            $(".btn_music>img").attr("src", "img/play.png")
        }
    })
}

// (function () {
//     setTimeout(function () {
//         $('.mailTop').fadeOut(10);
//         $('.mailBo').fadeOut(10);
//         // $('.mailTop').css('opacity', 0);
//         // $('.mailBo').css('opacity', 0);
//         // $('.mailClose').css('opacity', 1);
//     }, 25500);
// })()

// ***********************
$(document).ready(function () {
    var twidth = $(window).width();
    var theight = $(window).height();
    var zoomNum = theight / twidth;
    if (zoomNum < 1.55) {
        // //相应样式
        $(".container").css({
            'zoom': '0.9'
        });
    }
	var swiper2 = new Swiper('.swiper-container2', {
		 direction : 'vertical',
	    slidesPerView: 2,
	    spaceBetween: 48,
	    // freeMode: true,
	    // loop: true,
	    // centeredSlides: true,
	    navigation: {
	        nextEl: '.btn_next',
	        prevEl: '.btn_prev',
	    },
	});
    // 点击 开始我的第一约
    $("#showIndex").click(function () {
        $(this).addClass("animated pulse")
        setTimeout(() => {
            $(this).removeClass("animated pulse")
        }, 400);
        btnMusic.play()
        $(".custom").fadeIn().css({ "display": "flex" });
        $(".dinglan").css({ "display": "none" });
        $(".topMsg").css({ "display": "none" });
        $(".msgBox").css({ "display": "none" });
        $(".tools").css({ "display": "none" });
        $(".chat").css({ "display": "none" });
        $(".applet").css({ "display": "none" });
        $(".final").css({ "display": "none" });

        // 初始化轮播图
        var mySwiper = new Swiper('.swiper-container', {
            // loop: true, // 循环模式选项

            // 前进后退按钮
            navigation: {
                nextEl: '.next',
                prevEl: '.prev',
            }
        })
    });

    // 点击活动规则
    $(".custom__rules").click(function () {
        $(".rules").css({ "display": "flex" });
    });
    $(".rules-close").click(function () {
        $(".rules").css({ "display": "none" });
    });

    // 点击"我想说"选择框
    $("#say").click(function () {
        $("#say__ul").stop().slideToggle();
    });
    $("#say__ul li").click(function () {
        // console.log(this)
        $("#say__val").html($(this).text())
    });

    // 点击"何时约"选择框
    $("#time").click(function () {
        $("#time__ul").stop().slideToggle();
    });
    $("#time__ul li").click(function () {
        // console.log(this)
        $("#time__val").html($(this).text())
    });

    // 点击继续
    $(".custom__next").click(function () {
        btnMusic.play()
        $(this).addClass("animated pulse")
        setTimeout(() => {
            $(this).removeClass("animated pulse")
        }, 400);
        let imgSrc = $(".swiper-slide-active img").attr('src')
        switch (imgSrc) {
            case './img/scene1.png':
                $('.scenceAnimateDom1').fadeIn('fast');
                break;
            case './img/scene2.png':
                $('.scenceAnimateDom2').fadeIn('fast');
                break;
            case './img/scene3.png':
                $('.scenceAnimateDom3').fadeIn('fast');
                break;
            case './img/scene4.png':
                $('.scenceAnimateDom4').fadeIn('fast');
                break;
            default:
                break;
        }
        // $('#bg__img').prop('src', imgSrc)
        $(".custom").fadeOut()
        $(".invite").fadeIn()
        let sayTxt = $("#say__val").text()
        let timeTxt = $("#time__val").text()
        // console.log(sayTxt)
        let sayArr = sayTxt.split('，')
        // console.log(sayArr)
        if (sayArr.length == 2) {
            $(".invite__sayp1").html(sayArr[0])
            $(".invite__sayp2").html(sayArr[1])
        } else {
            $(".invite__sayp1").html(sayArr[0])
            $(".invite__sayp2").html(sayArr[1])
            $(".invite__sayp3").html(sayArr[2])
        }
        $(".invite__time").html(timeTxt)
        webwang.CrateRoom(sayTxt, timeTxt)
        var swiper1 = new Swiper('.swiper-container1', {
            slidesPerView: 5,
            spaceBetween: 35,
            // freeMode: true,
            // loop: true,
            // centeredSlides: true,
            navigation: {
                nextEl: '.next1',
                prevEl: '.prev1',
            },
        });
    });

    // 点击弹窗关闭
    $(".alart__imgClose").click(function () {
        $(".invite__alert").css({ "display": "none" })
    });

    // 点击马上就约
    $(".invite__btn").click(function () {
        btnMusic.play()
        $(this).addClass("animated pulse")
        setTimeout(() => {
            $(this).removeClass("animated pulse")
        }, 400);
        $(".mask_share").css({ "display": "block" });
    });
    /**点击再约一次 */
    $(".invite__btn02").click(function () {
        btnMusic.play()
        $(this).addClass("animated pulse")
        setTimeout(() => {
            $(this).removeClass("animated pulse")
        }, 400);
        // $(".mask_share").css({ "display": "block" });
        window.location.reload(); // 点击以后刷新
    });

    // 点击遮罩层返回
    $(".mask_share").click(function () {
        $(".mask_share").css({ "display": "none" })
    });

    // 点击中奖公告
    $(".notice-close").click(function () {
        $(".notice").css({ "display": "none" });
    });
})